package com.slipper.common.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Component;

import com.slipper.system.dictionary.service.DictionaryService;

@Component
public class DicUtil {
    private static DictionaryService dictionaryService;
    
    @Resource
    public void setDictionaryService(DictionaryService dictionaryService) {
        DicUtil.dictionaryService = dictionaryService;
    }
    
    public static void clearCache() {
    }
    
    public static void clearCache(String code) {
    }
    
    public static Map<String, List<Map<String, String>>> getAllDicData() {
        return dictionaryService.queryAllDicData();
    }
    
    public static Map<String, String> getDicData(String dicCode) {
        Map<Object, Object> cacheMap = dictionaryService.querySingleDicData(dicCode);
        
        Map<String, String> result = new HashMap<>();
        for (Map.Entry<Object, Object> entry : cacheMap.entrySet()) {
            result.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
        }
        return result;
    }
}
